<?php
/**
 * 定义 Controller_BoList 类
 *
 * @copyright Copyright (c) 2004 - 2009 iTeam
 * @author iTeam Monkey
 * @package XingYaoDianZi
 * @version 200912241050
 */

FLEA::loadClass('Controller_BoBase');
class Controller_BoList extends Controller_BoBase
{
    var $_tableEmails;
    var $_tableMessages;
    var $_tableOrders;
    var $_tableCoupon;
    var $access;
    var $dbo;	
	/**
     * 构造函数
     *
     * @return Controller_BoIndex
     */
    function Controller_BoList() {
        parent::Controller_BoBase();
        $this->access = LIST_ADMIN;
        $this->_tableMessages =& FLEA::getSingleton('Table_Messages');
        $this->_tableOrders =& FLEA::getSingleton('Table_Orders');
        //用户角色权限控制
        if(!$this->checkDispatcher($this->access)){
            redirect(url('BoDashboard','ErrorIn'));
        }
        $this->dbo = &FLEA::getDBO();
    }
	//订单列表    
    function actionIndex() {
    	$page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
        FLEA::loadClass('FLEA_Helper_Pager');       
        $pager =& new FLEA_Helper_Pager($this->_tableOrders, $page, 10, '', 'dateline DESC');
        $pk = $this->_tableOrders->primaryKey;
        $rowset = $pager->findAll("*",true);
        $this->_setBack();
//        dump($this->dbo->log);
        $listTitle = '订单列表';
        include(TPL_DIR . '/BoOrderList.php');
    } 
	//留言列表
    function actionMessage() {
        $page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
        FLEA::loadClass('FLEA_Helper_Pager');       
        $pager =& new FLEA_Helper_Pager($this->_tableMessages, $page, 10, '', 'dateline DESC');
        $pk = $this->_tableMessages->primaryKey;
        $rowset = $pager->findAll("*",true);
        $this->_setBack();
//        dump($this->dbo->log);
        $listTitle = '留言列表';
        include(TPL_DIR . '/BoMessageList.php');
    }
	//保存
    function actionSave() {
        __TRY();
        $arid = $this->_tableMessages->save($_POST);
        $ex = __CATCH();
        if (__IS_EXCEPTION($ex)) {
            return $this->_editArticle($_POST, $ex->getMessage());
        }
		redirect($this->_url('Message'));
    }
 	/**
     * 修改文章
     */
    function actionEdit() {
        $article = $this->_tableMessages->find((int)$_GET['id']);
        $this->_editArticle($article);
    }

    /**
     * 显示文章信息编辑页面
     *
     * @param array $article
     * @param string $errorMessage
     */
    function _editArticle($article, $errorMessage = '') {
        $pk = $this->_tableMessages->primaryKey;
        include(TPL_DIR . '/BoMessageEdit.php');
    }
	//删除资讯
    function actionRemove() {
        $this->_tableMessages->removeByPkv($_GET['id'],false);
        $this->_goBack();
    }
}